home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 3.2 / Ham Radio Version 3.2 (Chestnut CD-ROMs)(1993).ISO / packet / n17jsrc / ax25.h < prev    next >
C/C++ Source or Header  |  1991-07-09  |  8KB  |  246 lines

  1.  /* Mods by G1EMM */
  2. #ifndef    _AX25_H
  3. #define    _AX25_H
  4.  
  5. #ifndef    _GLOBAL_H
  6. #include "global.h"
  7. #endif
  8.  
  9. #ifndef    _MBUF_H
  10. #include "mbuf.h"
  11. #endif
  12.  
  13. #ifndef    _IFACE_H
  14. #include "iface.h"
  15. #endif
  16.  
  17. #ifndef    _SOCKADDR_H
  18. #include "sockaddr.h"
  19. #endif
  20.  
  21. /* AX.25 datagram (address) sub-layer definitions */
  22.  
  23. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  24. #define    ALEN        6    /* Number of chars in callsign field */
  25. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  26. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  27.  
  28. #ifndef _LAPB_H
  29. #include "lapb.h"
  30. #endif
  31.  
  32. /* Bits within SSID field of AX.25 address */
  33. #define    SSID        0x1e    /* Sub station ID */
  34. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  35. #define    E        0x01    /* Address extension bit */
  36. #define    C        0x80    /* Command/response designation */
  37.  
  38. /* Our AX.25 address */
  39. extern char Mycall[AXALEN];
  40.  
  41. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  42. extern char Ax25multi[][AXALEN];
  43.  
  44. extern int Digipeat;
  45. extern int Ax25mbox;
  46.  
  47. /* Number of chars in interface field. The involved definition takes possible
  48.  * alignment requirements into account, since ax25_addr is of an odd size.
  49.  */
  50. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  51.  
  52. /* Socket address, AX.25 style */
  53. struct sockaddr_ax {
  54.     short sax_family;        /* 2 bytes */
  55.     char ax25_addr[AXALEN];
  56.     char iface[ILEN];        /* Interface name */
  57. };
  58.  
  59. /* Internal representation of an AX.25 header */
  60. struct ax25 {
  61.     char dest[AXALEN];        /* Destination address */
  62.     char source[AXALEN];        /* Source address */
  63.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  64.     int ndigis;            /* Number of digipeaters */
  65.     int nextdigi;            /* Index to next digi in chain */
  66.     int cmdrsp;            /* Command/response */
  67. };
  68.  
  69. /* C-bit stuff */
  70. #define    LAPB_UNKNOWN        0
  71. #define    LAPB_COMMAND        1
  72. #define    LAPB_RESPONSE        2
  73.  
  74. /* AX.25 routing table entry */
  75. struct ax_route {
  76.     struct ax_route *next;        /* Linked list pointer */
  77.     char target[AXALEN];
  78.     char digis[MAXDIGIS][AXALEN];
  79.     int ndigis;
  80.     char type;
  81. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  82. #define    AX_AUTO        2        /* Set by incoming packet */
  83.     char mode;            /* Connection mode (G1EMM) */
  84. #define    AX_DEFMODE    0        /* Use default interface mode */
  85. #define    AX_VC_MODE    1        /* Try to use Virtual circuit */
  86. #define    AX_DATMODE    2        /* Try to use Datagrams only */
  87. };
  88. #define NULLAXR    ((struct ax_route *)0)
  89.  
  90. extern struct ax_route *Ax_routes;
  91. extern struct ax_route Ax_default;
  92.  
  93. /* AX.25 Level 3 Protocol IDs (PIDs) */
  94. #define PID_X25        0x01    /* CCITT X.25 PLP */
  95. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  96. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  97. #define    PID_LQ        0xc4    /* Link quality protocol */
  98. #define    PID_APPLETALK    0xca    /* Appletalk */
  99. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  100. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  101. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  102. #define    PID_RARP    0xce    /* ARPA Reverse Address Resolution Protocol */
  103. #define    PID_NETROM    0xcf    /* NET/ROM */
  104. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  105.  
  106. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  107. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  108.  
  109. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  110.  
  111. /* Link quality report packet header, internal format */
  112. struct lqhdr {
  113.     int16 version;        /* Version number of protocol */
  114. #define    LINKVERS    1
  115.     int32    ip_addr;    /* Sending station's IP address */
  116. };
  117. #define    LQHDR    6
  118. /* Link quality entry, internal format */
  119. struct lqentry {
  120.     char addr[AXALEN];    /* Address of heard station */
  121.     int32 count;        /* Count of packets heard from that station */
  122. };
  123. #define    LQENTRY    11
  124.  
  125. /* Link quality database record format
  126.  * Currently used only by AX.25 interfaces
  127.  */
  128. struct lq {
  129.     struct lq *next;
  130.     char addr[AXALEN];    /* Hardware address of station heard */
  131.     struct iface *iface;    /* Interface address was heard on */
  132.     int32 time;        /* Time station was last heard */
  133.     int32 currxcnt;    /* Current # of packets heard from this station */
  134.  
  135. #ifdef    notdef        /* Not yet implemented */
  136.     /* # of packets heard from this station as of his last update */
  137.     int32 lastrxcnt;
  138.  
  139.     /* # packets reported as transmitted by station as of his last update */
  140.     int32 lasttxcnt;
  141.  
  142.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  143.              * as of last update
  144.              */
  145.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  146.              * as of last update
  147.              */
  148. #endif
  149. };
  150. #define    NULLLQ    (struct lq *)0
  151.  
  152. extern struct lq *Lq;    /* Link quality record headers */
  153.  
  154. /* Structure used to keep track of monitored destination addresses */
  155. struct ld {
  156.     struct ld *next;    /* Linked list pointers */
  157.     char addr[AXALEN];/* Hardware address of destination overheard */
  158.     struct iface *iface;    /* Interface address was heard on */
  159.     int32 time;        /* Time station was last mentioned */
  160.     int32 currxcnt;    /* Current # of packets destined to this station */
  161. };
  162. #define    NULLLD    (struct ld *)0
  163.  
  164. extern struct ld *Ld;    /* Destination address record headers */
  165.  
  166. /* Linkage to network protocols atop ax25 */
  167. struct axlink {
  168.     int pid;
  169.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  170.      struct mbuf *,int));
  171. };
  172. extern struct axlink Axlink[];
  173.  
  174. /* Codes for the open_ax25 call */
  175. #define    AX_PASSIVE    0
  176. #define    AX_ACTIVE    1
  177. #define    AX_SERVER    2    /* Passive, clone on opening */
  178.  
  179. /* Max number of fake AX.25 interfaces for RFC-1226 encapsulation */
  180. #define    NAX25        10
  181.  
  182. #define    AXHEARD_PASS    0    /* Log both src and dest callsigns */
  183. #define    AXHEARD_NOSRC    1    /* do not log source callsign */
  184. #define    AXHEARD_NODST    2    /* do not log destination callsign */
  185. #define    AXHEARD_NONE    3    /* do not log any callsign */
  186.  
  187. /* In ax25.c: */
  188. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  189. int ax_drop __ARGS((char *));
  190. struct ax_route *ax_lookup __ARGS((char *));
  191. void axip_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,int rxbroadcast));
  192. void ax_recv __ARGS((struct iface *,struct mbuf *));
  193. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  194.     int del,int tput,int rel));
  195. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  196.     struct mbuf *data));
  197. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  198. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  199.     char *dest,struct mbuf *bp,int mcast));
  200.  
  201. /* In ax25cmd.c: */
  202. void st_ax25 __ARGS((struct ax25_cb *axp));
  203.  
  204. /* In axhdr.c: */
  205. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  206. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  207.  
  208. /* In axlink.c: */
  209. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  210. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  211. void logsrc __ARGS((struct iface *iface,char *addr));
  212. void logdest __ARGS((struct iface *iface,char *addr));
  213. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  214. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  215. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  216.  
  217. /* In ax25user.c: */
  218. int ax25val __ARGS((struct ax25_cb *axp));
  219. int disc_ax25 __ARGS((struct ax25_cb *axp));
  220. int kick_ax25 __ARGS((struct ax25_cb *axp));
  221. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  222.     int,int16,
  223.     void (*) __ARGS((struct ax25_cb *,int)),
  224.     void (*) __ARGS((struct ax25_cb *,int)),
  225.     void (*) __ARGS((struct ax25_cb *,int,int)),
  226.     int user));
  227. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  228. int reset_ax25 __ARGS((struct ax25_cb *axp));
  229. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  230.  
  231. /* In ax25subr.c: */
  232. int addreq __ARGS((char *a,char *b));
  233. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  234. void del_ax25 __ARGS((struct ax25_cb *axp));
  235. struct ax25_cb *find_ax25 __ARGS((char *));
  236. char *pax25 __ARGS((char *e,char *addr));
  237. int setcall __ARGS((char *out,char *call));
  238.  
  239. /* In socket.c: */
  240. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  241. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  242. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  243. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  244.  
  245. #endif    /* _AX25_H */
  246.